%%
%% This is file `ifplatform.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% ifplatform.dtx  (with options: `package')
%%   _________________________________________________________
%%   Copyright (C) 2007, 2009  Will Robertson & Johannes Große
%%   License information appended.
\ProvidesPackage{ifplatform}
  [2009/09/10 v0.3a  Testing for the operating system]
\RequirePackage{pdftexcmds,catchfile}
\newif\ifshellescape
\newif\ifwindows
\newif\ifmacosx
\newif\iflinux
\newif\ifcygwin
\newcommand\windowsname{Windows}
\newcommand\notwindowsname{*NIX}
\newcommand\linuxname{Linux}
\newcommand\macosxname{Mac\,OS\,X}
\newcommand\cygwinname{Cygwin}
\newcommand\unknownplatform{[Unknown]}
\edef\ip@file{\jobname.w18}
\newif\if@ip@nix@
\ifnum\pdf@shellescape=1\relax
  \shellescapetrue
\else
  \PackageWarningNoLine{ifplatform}{^^J \space\space\space
    shell escape is disabled,
    so I can only detect \@backslashchar ifwindows%
  }
\fi
\def\ip@cantdecide{%
  \PackageWarningNoLine{ifplatform}{^^J \space\space\space
    I can't tell if this is Windows or *nix;
    you appear to be both%
  }%
}
\IfFileExists{nul:}{\@ip@nix@false}{\@ip@nix@true}
\IfFileExists{/dev/null}{\windowsfalse}{\windowstrue}
\edef\ip@windows@echo@test{echo \string# > "\ip@file"}
\def\ip@backupplan{%
  \IfFileExists{\ip@file}{%
    \PackageWarningNoLine{ifplatform}{^^J \space\space\space
      Please delete the file "\ip@file" and try again%
    }%
    \ip@cantdecide
  }{%
    \immediate\write18{\ip@windows@echo@test}%
    \IfFileExists{\ip@file}{%
      \immediate\write18{del "\ip@file"}%
      \windowstrue
    }{%
      \@ip@nix@true
    }%
  }%
}
\ifwindows
  \if@ip@nix@
    \PackageWarningNoLine{ifplatform}{^^J \space\space\space
      I can't tell if this is Windows or *nix;
      you appear to be neither%
    }
  \fi
\else
  \if@ip@nix@\else
    \ifshellescape
      \ip@backupplan
    \else
      \ip@cantdecide
    \fi
  \fi
\fi
\def\ip@only@six#1#2#3#4#5#6#7\@nil{#1#2#3#4#5#6}
\if@ip@nix@
\ifshellescape
  \ifwindows\else
    \immediate\write18{uname -s > "\ip@file"}
    \CatchFileDef\@tempa{\ip@file}{}
    \immediate\write18{rm -- "\ip@file"}
    \edef\@tempa{\expandafter\zap@space\@tempa\@empty}
    \def\@tempb{Linux}
    \ifx\@tempa\@tempb
      \linuxtrue
    \else
      \def\@tempb{Darwin}
      \ifx\@tempa\@tempb
        \macosxtrue
      \else
        \def\@tempb{CYGWIN}
        \edef\@tempc{\expandafter\ip@only@six\@tempa------\@nil}
        \ifx\@tempb\@tempc
          \cygwintrue
        \else
          \edef\unknownplatform{\@tempa}
        \fi
      \fi
    \fi
  \fi
\fi\fi
\edef\platformname{%
  \ifwindows
    \noexpand\windowsname
  \else
    \ifshellescape
      \iflinux
        \noexpand\linuxname
      \else
        \ifmacosx
          \noexpand\macosxname
        \else
          \ifcygwin
            \noexpand\cygwinname
          \else
            \noexpand\unknownplatform
          \fi
        \fi
      \fi
    \else
      \noexpand\notwindowsname
    \fi
  \fi
}
%% Copyright (C) 2007, 2009 by Will Robertson & Johannes Große
%% 
%% Distributable under the LaTeX Project Public License,
%% version 1.3c or higher (your choice). The latest version of
%% this license is at: http://www.latex-project.org/lppl.txt
%% 
%% This work is "author-maintained" by Will Robertson.
%% 
%% This work consists of the file  ifplatform.dtx
%%           and the derived files ifplatform.pdf,
%%                                 ifplatform.sty, and
%%                                 ifplatform.ins.
%%
%% End of file `ifplatform.sty'.
